'use strict'

const pg=require('pg')

let psql=new pg.Pool({
    host:'127.0.0.1',
    port:5432,
    user:'liyanping',
    password:'201304lyp',
    database:'liyanping',
    // 最大客户端连接数量
    max:8
});

// js不需要加分号，但是以()开头的需要加分号

(async ()=>{
    let sqltext=`insert into `+`content(id,title,detail,add_time,update_time)`+` values($1,$2,$3,$4,$5)`

    let tm=Date.now()

    //query接口实现对数据库的操作
    let ret=await psql.query(sqltext,[
        `${tm}`,
        `${Math.random()}`,
        '测试内容',
        tm,
        tm
    ])

    let ret2=await psql.query(`select * from content`)

    psql.end()

    console.log(ret,ret2)
})();


